__author__ = 'guo'

from bs4 import BeautifulSoup
import urllib
import json
from django.http import HttpResponse
import re

def convert(self, name):
	return eval("u'" + name.replace('%','\\') + "'").encode('utf-8').decode("utf-8")

def getXmlInfo(self, html, info, parmCode, starDate, endDate, parameterGather):
	xml = ""
	return xml

def OutJson(code,msg, url=""):
	dic = {}
	dic['statusCode'] = code
	dic['message'] = msg
	dic['navTabId'] = ""
	dic['callbackType'] = ""
	dic['forwardUrl'] = url
	returnJson = json.dumps(dic)
	return HttpResponse(returnJson, content_type='application/json')



def checkUser(username=None):
	if username:
		#email
		if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", username) != None:
				return "EMAIL"
		#mobile
		elif len(username)==11 and re.match("^(1[3458]\d{9})$", username) != None:
			return "MOBILE"
		#nick
		else:
			return "STR"
	else:
		return None